package com.fmsh.nfcsensor.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author wuyajiang
 * @date 2022/11/7
 */
public class SensorBean implements Parcelable {

    public int type;  // 类型 0 温度 1湿度 2气压 3光照 4气体
    public int typeId;   // 类型
    public int imageId;  // 图片
    public double value; // 值
    public String unity; // 单位

    private long time; // 时间

    @Override
    public String toString() {
        return "SensorBean{" +
                "type=" + type +
                ", typeId=" + typeId +
                ", imageId=" + imageId +
                ", value=" + value +
                ", unity='" + unity + '\'' +
                ", time=" + time +
                ", detail='" + detail + '\'' +
                '}';
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String detail = ""; // 详情

    public String getUnity() {
        return unity;
    }

    public String getDetail() {
        switch (unity){
            case "℃":
//                if(value >= 20 && value < 30){
//                    detail = "舒适";
//                }
//                if(value< 20){
//                    detail =  "冷";
//                }
//                if(value>30){
//                    detail = "炎热";
//                }
                break;
            case "%RH":
//                if(value > 40){
//                    return "舒适";
//                }
//                detail =  "舒适";
                break;
            case "Pa":
                break;
            case "LUX":
                break;
        }
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public void setUnity(String unity) {
        this.unity = unity;
    }

    public int getTypeId() {
        return typeId;
    }

    public void setTypeId(int typeId) {
        this.typeId = typeId;
    }

    public int getImageId() {
        return imageId;
    }

    public void setImageId(int imageId) {
        this.imageId = imageId;
    }

    public double getValue() {
        return value;
    }

    public void setValue(double value) {
        this.value = value;
    }

    public SensorBean() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.type);
        dest.writeInt(this.typeId);
        dest.writeInt(this.imageId);
        dest.writeDouble(this.value);
        dest.writeString(this.unity);
        dest.writeLong(this.time);
        dest.writeString(this.detail);
    }

    protected SensorBean(Parcel in) {
        this.type = in.readInt();
        this.typeId = in.readInt();
        this.imageId = in.readInt();
        this.value = in.readDouble();
        this.unity = in.readString();
        this.time = in.readLong();
        this.detail = in.readString();
    }

    public static final Creator<SensorBean> CREATOR = new Creator<SensorBean>() {
        @Override
        public SensorBean createFromParcel(Parcel source) {
            return new SensorBean(source);
        }

        @Override
        public SensorBean[] newArray(int size) {
            return new SensorBean[size];
        }
    };
}
